package io;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 利用缓冲字符输入流将/src/main/java目录下的所有.java文件内容输入到控制台
 */
public class Test7 {
    public static void main(String[] args) throws IOException {
        File dir = new File("./src/main/java/io");
        //2
        File[] subs = dir.listFiles(f->f.getName().endsWith(".java"));
        //3
        for(File sub : subs){
            FileInputStream fis = new FileInputStream(sub);
            InputStreamReader isr = new InputStreamReader(fis);
            BufferedReader br= new BufferedReader(isr);
            String line;
            while ((line = br.readLine())!=null) {
                System.out.println(line);
            }
            br.close();
        }
    }
}
